import { createRouter, createWebHistory } from 'vue-router';
import Login from '../views/Login.vue';
import Layout from '../views/User/Layout.vue'; // 引入 Layout 组件
import Home from '../views/User/Home.vue'; // 引入 Home 组件
import Location from '../views/User/Location.vue'; // 引入 党建地点 组件
import Forum from '../views/User/Forum.vue'; // 引入 论坛 组件
import News from '../views/User/News.vue'; // 引入 公告资讯 组件
import Store from '../views/User/Store.vue'; // 引入 商城 组件
import PersonalCenter from '../views/User/profile.vue'; // 引入 个人中心 组件

const routes = [
  { path: '/', name: 'Login', component: Login }, // 登录路由
  { 
    path: '/user', 
    name: 'Layout', 
    component: Layout, 
    redirect: '/user/home',
    children: [
      { path: '/user/home', name: 'Home', component: Home }, // 首页
      { path: '/user/location', name: 'Location', component: Location }, // 党建地点
      { path: '/user/forum', name: 'Forum', component: Forum }, // 论坛
      { path: '/user/news', name: 'News', component: News }, // 公告资讯
      { path: '/user/store', name: 'Store', component: Store }, // 商城
      { path: '/user/profile', name: 'PersonalCenter', component: PersonalCenter }, // 个人中心
    ] 
  },
];

const router = createRouter({
  history: createWebHistory(),
  routes,
});

export default router;
